home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / dsp / c5xug.exe / FRAC32.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-05-02  |  1.5 KB  |  60 lines

  1. ;**************************************************************
  2. ;  
  3. ;                 frac32.asm
  4. ;  
  5. ;                 staff
  6. ;  
  7. ;                 05-02-91
  8. ;  
  9. ;           (C) Texas Instruments Inc., 1992 
  10. ;  
  11. ;           Refer to the file 'license.txt' included with this 
  12. ;           this package for usage and license information. 
  13. ;  
  14. ;**************************************************************
  15. Example 7-xy. 32-bit Fractional Multiplication
  16.  
  17.  
  18.  
  19.    .title "32-bit Fractional Multiplication"
  20.  
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ; This routine multiplies two Q31 signed integers resulting
  23. ; in a Q30 product. The operands are fetched from data
  24. ; memory and the result is written back to data memory.
  25. ; Data Storage:
  26. ;    X1,X0        Q31 operand
  27. ;    Y1,Y0        Q31 operand
  28. ;    W1,W0        Q30 product
  29. ; Entry Conditions:
  30. ;    DP  = 6, SXM = 1
  31. ;    OVM = 0
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33.  
  34. X1     .set    300h    ;DP=6
  35. X0     .set    301h    ;DP=6
  36. Y1     .set    302h    ;DP=6
  37. Y0     .set    303h    ;DP=6
  38. W1     .set    304h    ;DP=6
  39. W0     .set    305h    ;DP=6
  40.  
  41.  
  42.        .text
  43.  
  44.     BIT    X0,0    ; TC = X0 bit#15
  45.     LT    X0    ; TREG0 = X0
  46.     MPY    Y1    ; P = X0*Y0
  47.     LTP    X1    ; Acc = X0*Y0
  48.     MPY    Y0    ; P = X1*Y0
  49.     MPYA    Y1    ; Acc = X0*Y0 + X1*Y0
  50.     BSAR    16    ; Throw away low 16 bits
  51.     XC    1,TC    ; If MSB of X0 is 1
  52.     ADD    Y1    ; then add Y1
  53.     BIT    Y0,0    ; TC = Y0 bit#15
  54.     APAC        ; Acc = Acc + X1*Y1
  55.     XC    1,TC    ; If MSB of Y0 is 1
  56.     ADD    X1    ; then add X1
  57.     SACL    W0    ; Save lower product
  58.     SACH    W1    ; Save upper product
  59.  
  60.